﻿using RpcCentral.Model;
using RpcCentral.Model.DB;
using SqlSugarHelper;

namespace RpcCentral.DAL.Repository
{
    internal class RemoteServerGroupDAL : IRemoteServerGroupDAL
    {
        private IRepository<RemoteServerGroup> _Db;
        public RemoteServerGroupDAL(IRepository<RemoteServerGroup> db)
        {
            _Db = db;
        }
        public long[] GetRpcMer(long systemTypeId)
        {
            return this._Db.Gets(c => c.SystemType == systemTypeId, c => c.RpcMerId);
        }
        public RemoteConfig[] GetRemoteServer(long rpcMerId, long systemTypeId)
        {
            return this._Db.Gets(c => c.RpcMerId == rpcMerId && c.SystemType == systemTypeId, c => new RemoteConfig
            {
                ServerId = c.ServerId,
                Weight = c.Weight
            });
        }
        public long[] GetRemoteServerId(long rpcMerId, long systemTypeId)
        {
            return this._Db.Gets(c => c.RpcMerId == rpcMerId && c.SystemType == systemTypeId, c => c.ServerId);
        }
    }
}
